package com.dolphin.aiagentplatform.ai.client;

import com.dolphin.aiagentplatform.ai.constant.ModelTypeConst;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class ChatClientFactory {

    @Resource
    private DeepSeekR1ClientGenerator deepSeekR1ClientGenerator;

    @Resource
    private DeepSeekV3ClientGenerator deepSeekV3ClientGenerator;

    @Resource
    private QwenMaxClientGenerator qwenMaxClientGenerator;

    private final Map<ModelTypeConst, ChatClientStrategy> clientMap = new HashMap<>();

    @PostConstruct
    public void init() {
        clientMap.put(ModelTypeConst.DEEPSEEK_R1, deepSeekR1ClientGenerator);
        clientMap.put(ModelTypeConst.DEEPSEEK_V3, deepSeekV3ClientGenerator);
        clientMap.put(ModelTypeConst.QWEN_MAX, qwenMaxClientGenerator);
    }

    public ChatClientStrategy getChatClient(ModelTypeConst modelType) {
        ChatClientStrategy client = clientMap.get(modelType);
        if (client == null) {
            throw new IllegalArgumentException("Unsupported model type: " + modelType);
        }
        return client;
    }

    public List<ModelTypeConst> getAllSupportedModelTypes() {
        return List.copyOf(clientMap.keySet());
    }
} 